package com.wy.jetpack.viewmodel;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;


//livedata +viewmodel
public class LiveDataVM extends ViewModel {

    private MutableLiveData<Integer> cxk, jay;


    public MutableLiveData<Integer> getCxk() {
        if (cxk == null) {
            cxk = new MutableLiveData<>();
            cxk.setValue(10);
        }
        return cxk;
    }


    public MutableLiveData<Integer> getJay() {
        if (jay == null) {
            jay = new MutableLiveData<>();
            jay.setValue(0);
        }
        return jay;
    }

    public void addCxk() {
        if (cxk != null) {
            cxk.setValue(cxk.getValue() + 1);
        }
    }

    public void addJay() {
        if (jay != null) {
            jay.setValue(jay.getValue() + 1);
        }
    }
}
